package com.apimanage.common.health;

import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.List;

/**
 * 健康检查结果类
 * 存储健康检查的结果信息
 *
 * @author API管理平台
 */
public class HealthCheckResult {
    
    private boolean healthy;
    private String componentName;
    private LocalDateTime checkTime;
    private long responseTime;
    private List<String> messages = new ArrayList<>();
    
    public HealthCheckResult() {
        this.checkTime = LocalDateTime.now();
    }
    
    public HealthCheckResult(boolean healthy, String componentName) {
        this.healthy = healthy;
        this.componentName = componentName;
        this.checkTime = LocalDateTime.now();
    }
    
    public boolean isHealthy() {
        return healthy;
    }
    
    public void setHealthy(boolean healthy) {
        this.healthy = healthy;
    }
    
    public String getComponentName() {
        return componentName;
    }
    
    public void setComponentName(String componentName) {
        this.componentName = componentName;
    }
    
    public LocalDateTime getCheckTime() {
        return checkTime;
    }
    
    public void setCheckTime(LocalDateTime checkTime) {
        this.checkTime = checkTime;
    }
    
    public long getResponseTime() {
        return responseTime;
    }
    
    public void setResponseTime(long responseTime) {
        this.responseTime = responseTime;
    }
    
    public List<String> getMessages() {
        return messages;
    }
    
    public void setMessages(List<String> messages) {
        this.messages = messages;
    }
    
    public void addMessage(String message) {
        this.messages.add(message);
    }
    
    @Override
    public String toString() {
        return "HealthCheckResult{" +
                "healthy=" + healthy +
                ", componentName='" + componentName + '\'' +
                ", checkTime=" + checkTime +
                ", responseTime=" + responseTime +
                ", messages=" + messages +
                '}';
    }
}